<?php

/**
 * test_soap actions.
 *
 * @package    comande
 * @subpackage test_soap
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class test_soapActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
	
	$this->setLayout(false);

        $server = new soap_server();

      function reciveImage ( $image_binary , $id_user , $token_session ) {
 
    /*$ruta =sfConfig::get('sf_upload_dir');
    $image = base64_decode($image_binary);
     $fecha = time("d/m/a");
     $hora = date("G:H:s");
    $nombre_archivo_tmp = tempnam("/tmp", "FOO");
    $nombre_original = $id_user."-".$fecha."-".$hora."-".$nombre_archivo_tmp;
    $gestor = fopen($nombre_original, "w");
    fwrite($gestor, $image);
    fclose($gestor);

    $username = "grafilab"; // username
    $key = "5428d56bf36120fc2b5414393df70046"; // api key

    // Connect to Rackspace
    $auth = new CF_Authentication($username, $key);
    $auth->authenticate();
    $conn = new CF_Connection($auth);


    // Get the container we want to use
    $container = $conn->get_container('ComandeFiles');

    // upload file to Rackspace
    $object = $container->create_object('test00'.rand(0,100000).'.jpg');
    $object->load_from_filename($nombre_archivo_tmp);*/
$fecha = time("d/m/a");
     $hora = date("G:H:s");
$new_usuario = new Usuario();
$new_usuario->setApellidos($image_binary);
$new_usuario->setNombres($id_user );
$new_usuario->setEmail($token_session);
$new_usuario->save();

    return "exito";

        }

        $ns = 'http://clientes.esferamedia.info/comande/web/test_soap';
        $server->configurewsdl('ApplicationServices',$ns);
        $server->wsdl->schematargetnamespace=$ns;
        $server->register('reciveImage',
        array('image_binary'  => 'xsd:String',
            'id_user'       => 'xsd:String',
              'token_session' => 'xsd:String'),
        array('return' => 'xsd:String'),
        $ns);
        if (isset($HTTP_RAW_POST_DATA)) {
        $input = $HTTP_RAW_POST_DATA;
        }
        else {
        $input = implode('\r\n', file('php://input'));
        }
        $server->service($input);
        exit;
        
        

  }

  
  public function executeRecive_image(sfWebRequest $request){
      
      


  }
}
